<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Tests CSS parser autocloses braces.</title>
  <style type="text/css" media="screen">
    @keyframes foo {
        from { left: 100px; }
        40%  { left: 200px; }
        60%  { left: 200px; }
        to   { left: 300px;
  </style>
  <script src="../resources/testharness.js"></script>
  <script src="../resources/testharnessreport.js"></script>
  <script type="text/javascript" charset="utf-8">
    var asyncHandle = async_test("Tests parsing the @keyframes rule without closing brace. 'User agents must close all open constructs ... at the end of the style sheet.'(http://www.w3.org/TR/CSS21/syndata.html#parsing-errors). So it must be parsed as if all braces are closed");

    function findKeyframesRule(rule)
    {
        var ss = document.styleSheets;
        for (var i = 0; i < ss.length; ++i) {
            for (var j = 0; j < ss[i].cssRules.length; ++j) {
                if (ss[i].cssRules[j].type == window.CSSRule.KEYFRAMES_RULE && ss[i].cssRules[j].name == rule)
                    return ss[i].cssRules[j];
            }
        }

        return null;
    }

    function test()
    {
        var keyframes = findKeyframesRule("foo");
        var length = keyframes ? keyframes.cssRules.length : undefined;
        assert_equals(length, 4, 'keyframes rule should have length 4');
    }

    window.onload = asyncHandle.step_func_done(test);
  </script>
</head>
<body>
</body>
</html>
